<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vant@1.6/lib/index.css">
		<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.min.js"></script>
		<script src="https://cdn.jsdelivr.net/npm/vant@1.6/lib/vant.min.js"></script>
		<script src="../js/listener_other.js"></script>
		<script src="../js/ajax.js"></script>
		<title>修改昵称</title>
	</head>
	<body>
			<div id="app">
				<van-row>
					<van-col span="24">
						<van-nav-bar title="修改昵称" 
						left-arrow right-text="确认修改"
						 @click-left="onClickLeft"
						  @click-right="onClickRight"
						  style="background-color: red;
						  padding:5px;"
						  >
						</van-nav-bar>
					</van-col>
					<van-col span="24">
						<van-cell-group>
							<van-field placeholder="请输入用户名" v-model="NickName" />
						</van-cell-group>
					</van-col>
				</van-row>
			</div>
			<script>
				var vm = new Vue({
					el: "#app",
					data: {
						NickName: ""
					},
					methods: {
						onClickLeft() {
							plus.webview.close(plus.webview.currentWebview(), "slide-out-left");
						},
						onClickRight() {
							if (confirm('确定要更改吗') == true) {
								var _this = this
								ajax({
									url: "http://dsapi.ysd3g.com/API/ChangeNickName",
									data: {
										key:localStorage.getItem("key")	,
										NickName:_this.NickName
									},
									dataType: "jsonp",
									success: function(res) {	
										if (!res.Error) {
											var NickName=localStorage.getItem("NickName");
											NickName=_this.NickName;
											console.log(NickName)
											localStorage.setItem("NickName",NickName);
											plus.webview.getWebviewById("profile").reload(true);
											alert("修改成功")
											plus.webview.close(plus.webview.currentWebview());
											plus.webview.getWebviewById("setas").reload(true);
										} else {
											alert(res.Msg)
										}
									}
								})
							} else {
								alert("已取消更改")
							}
						}
					},
					mounted() {
						this.NickName = localStorage.getItem('NickName')
					}
				})
			</script>
		</body>
	</html>
	